public class Arrays <T extends Comparable<? super T>>{
	
	public Arrays(){
		
	}
	
	public T[] intersectionNoOrder(T[] arr1, T[] arr2){
		int min;
		if(arr1.length<arr2.length){
			min=arr1.length;
		}
		else{
			min=arr2.length;
		}
		int intSize=0;
		T[] ans=(T[]) new Object[min];
		
		for(int i=0;i<arr1.length;i++){
			for(int j=0;j<arr2.length;j++){
				if(arr1[i].compareTo(arr2[j])==0){
					ans[intSize]=arr1[i];
					intSize++;
				}
			}
		}
		
		
		return ans;
	}
	
	public T[] intersectionOrdered(T[] arr1, T[] arr2){
		int min;
		if(arr1.length<arr2.length){
			min=arr1.length;
		}
		else{
			min=arr2.length;
		}
		
		int intSize=0;
		T[] ans=(T[]) new Object[min];
		
		for(int i=0;i<arr1.length;i++){
			for(int j=i;j<arr2.length;j++){
				if(arr1[i].compareTo(arr2[j])==0){
					ans[intSize]=arr1[i];
					intSize++;
				}
			}
		}
		
		return ans;
	}
	
}
